.PHONY: help proxy wtf init dev

help:
	@echo "help                 显示帮助信息"
	@echo "install              初始化项目"
	@echo "lint                 检查代码格式"
	@echo "dev                  运行前端开发工作流"
	@echo "init-help            线上机器初始化步骤"

install:
  # 建议不要直接使用 cnpm 安装以来，会有各种诡异的 bug。可以通过如下操作解决 npm 下载速度慢的问题
  # npm install --registry=https://registry.npm.taobao.org
	npm install --verbose

dev:
	@echo "在 mac 下需要 sudo 权限才能使用启动 80 端口"
	npm run dev

lint:
	@echo "在 mac 下需要 sudo 权限才能使用启动 80 端口"
	npm run lint

wtf:
	@echo "别气馁, 慢慢来:)"

.PHONY: install-help init-help
install-help init-help:
	@echo "虚拟机初始化按照以下步骤执行："
	@echo "1、 yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel gcc-c++"
	@echo "2、 wget http://nginx.org/download/nginx-1.18.0.tar.gz"
	@echo "3、 tar -xvf nginx-1.18.0.tar.gz;cd nginx-1.18.0;./configure --prefix=/usr/local/nginx;make;make install"
	@echo "4、 mkdir -p /usr/local/nginx/ROOT_WEB;mkdir /data/deploy_code;mkdir /data/deploy_package"
	@echo "4、 yum -y install npm;npm install -g n;n 12.10.0"


# $(1): log level
# $(2): log message
define mtlog
	@if [ x"$(1)" = x"error" ]; then echo "\033[41;30;1m[ERROR] $(2)\033[0m"; fi
	@if [ x"$(1)" = x"warn" ]; then echo "\033[43;30;1m[WARNING] $(2)\033[0m"; fi
	@if [ x"$(1)" = x"warning" ]; then echo "\033[43;30;1m[WARNING] $(2)\033[0m"; fi
	@if [ x"$(1)" = x"info" ]; then echo "\033[47;30;1m[INFO] $(2)\033[0m"; fi
	@if [ x"$(1)" = x"debug" ]; then echo "[DEBUG] $(2)"; fi
endef

